$(function() {
	//判断登陆状态
	var userInfo = getLocalUserInfo();
	checkUserLogin();
	console.log(userInfo);
    window.pageLoad = function () {     
        $('.user_name').html('<span class="name">'+userInfo.LoginName+'</span>');
     
        $('body').on('tap', "#logoutbtn", function () {
	        layer.open({
		        shadeClose: false,
		        content: '是否确定退出'
		        , btn: ['确定', '取消']
		        , yes: function (index) {
		        	userLogout();
		        	 WeixinJSBridge.invoke('closeWindow',{},function(res){
					 });
		        }
	        });
        });
    };
    pageLoad();
    mui.init({
        keyEventBind: {
            backbutton: true //开启back按键监听
        }
    });
    mui.plusReady(function () {
        var tuichu = "再按一次退出程序";
        var backButtonPress = 0;

        // 关闭所有无用窗口
        clearAllWindows();
        mui.back = function(event) {
            backButtonPress++;
            if(backButtonPress > 1) {
                var main = plus.android.runtimeMainActivity();
                main.moveTaskToBack(false);
                return false;
            } else {
                plus.nativeUI.toast(tuichu);
            }
            setTimeout(function() {
                backButtonPress = 0;
            }, 1000);
            return false;
        };
       });

    window.pageReload = function () {
        console.log(1111);
        pageLoad();
    }

});